import React from "react";
import { Navigate, Route, Routes } from "react-router-dom";
import { ProtectedRoute } from "./ProtectedRoute";
import { ROUTES } from "../constants/routes";
import DoctorDashboard from "../pages/Doctor/Dashboard";
import PatientDashboard from "../pages/Patient/Dashboard";
import PatientDetail from "../pages/Doctor/PatientDetail";
import EMRList from "../pages/Doctor/EMRList";
import RegisterAppointment from "../pages/Patient/RegisterAppointment";
import PatientConsultChat from "../pages/Patient/ConsultChat";
import PatientConsultList from "../pages/Patient/ConsultList";
import MedicalRecords from "../pages/Patient/MedicalRecords";
import DeviceMonitoring from "../pages/Patient/DeviceMonitoring";
import DoctorConsultChat from "../pages/Doctor/ConsultChat";
import DoctorConsultManager from "../pages/Doctor/ConsultManager";
import Pharmacy from "../pages/Doctor/Pharmacy";
import Statistics from "../pages/Doctor/Statistics";
import Examination from "../pages/Doctor/Examination";
import Emergency from "../pages/Doctor/Emergency";
import Login from "../pages/Auth/Login";
import NotFound from "../pages/NotFound";

const AppRoutes: React.FC = () => {
    return (
        <Routes>
            <Route path={ROUTES.login} element={<Login />} />

            <Route element={<ProtectedRoute allowedRoles={["doctor"]} />}>
                <Route path={ROUTES.doctor.root} element={<Navigate to={ROUTES.doctor.dashboard} replace />} />
                <Route path={ROUTES.doctor.dashboard} element={<DoctorDashboard />} />
                <Route path={ROUTES.doctor.patientDetail} element={<PatientDetail />} />
                <Route path={ROUTES.doctor.emrList} element={<EMRList />} />
                <Route path={ROUTES.doctor.consultChat} element={<DoctorConsultChat />} />
                <Route path={ROUTES.doctor.consultManager} element={<DoctorConsultManager />} />
                <Route path={ROUTES.doctor.pharmacy} element={<Pharmacy />} />
                <Route path={ROUTES.doctor.statistics} element={<Statistics />} />
                <Route path={ROUTES.doctor.examination} element={<Examination />} />
                <Route path={ROUTES.doctor.emergency} element={<Emergency />} />
            </Route>

            <Route element={<ProtectedRoute allowedRoles={["patient"]} />}>
                <Route path={ROUTES.patient.root} element={<Navigate to={ROUTES.patient.dashboard} replace />} />
                <Route path={ROUTES.patient.dashboard} element={<PatientDashboard />} />
                <Route path={ROUTES.patient.registerAppointment} element={<RegisterAppointment />} />
                <Route path={ROUTES.patient.consultChat} element={<PatientConsultChat />} />
                <Route path={ROUTES.patient.consultList} element={<PatientConsultList />} />
                <Route path={ROUTES.patient.medicalRecordQuery} element={<MedicalRecords />} />
                <Route path={ROUTES.patient.deviceMonitoring} element={<DeviceMonitoring />} />
            </Route>

            <Route path="/" element={<Navigate to={ROUTES.login} replace />} />
            <Route path={ROUTES.notFound} element={<NotFound />} />
        </Routes>
    );
};

export default AppRoutes;


